package com.nexgo.payment.trans.ecsale;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.nexgo.payment.constrant.CardMode;
import com.nexgo.payment.databases.Repository;
import com.nexgo.payment.trans.AbsTransActivity;

/**
 * 电子现金界面
 * 根据类型分：普通支付、快速支付
 * Created by wanghongyang on 2017/8/31.
 */
public class EcSaleActivity extends AbsTransActivity<EcSaleContract.Presenter> implements EcSaleContract.View {
    private static final String CARD_MODE = "card_mode";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CardMode cardMode = null;
        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            cardMode = CardMode.values()[bundle.getInt(CARD_MODE, 0)];
        }
        new EcSalePresenter(this, Repository.getInstance(), cardMode);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mPresenter.start();
    }

    public static Intent newInstance(Context context, CardMode cardMode) {
        Intent intent = new Intent(context, EcSaleActivity.class);
        if (cardMode != null) {
            Bundle bundle = new Bundle();
            bundle.putInt(CARD_MODE, cardMode.ordinal());
            intent.putExtras(bundle);
        }
        return intent;
    }
}
